<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div style="margin-left: 300px;margin-top: 50px">
    <div>
        post message test
    </div>

    <button class='btn'>
        点我发送
    </button>
</div>


        <script>

            window.onload=function () {

              var btn=  document.querySelector('.btn')

                btn.onclick=function () {
                    if(window.postMessage) {
                        alert('开始发送了。。。')
                        window.postMessage('来自柳纯，测试postmsg===,接受到表示成功');
                    }
                }
            }
        </script>

</body>
</html>